home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / EntertheTroy.dxr / 00020_Graphics Handlers.ls < prev    next >
Encoding:
Text File  |  2002-01-31  |  4.3 KB  |  129 lines

  1. global updateTextFields
  2.  
  3. on initializeScreen
  4.   global terrainSO, screenDimensions, screenTileSize
  5.   maxX = screenDimensions[1]
  6.   maxY = screenDimensions[2]
  7.   wTile = 0
  8.   repeat with whichY = 1 to maxY
  9.     repeat with whichX = 1 to maxX
  10.       wSprite = terrainSO + wTile
  11.       puppetSprite(wSprite, 1)
  12.       set the member of sprite wSprite to "Iron Block"
  13.       set the loc of sprite wSprite to point((whichX - 1) * screenTileSize, (whichY - 1) * screenTileSize)
  14.       wTile = wTile + 1
  15.     end repeat
  16.   end repeat
  17. end
  18.  
  19. on repositionTerrain
  20.   global terrainSO, screenDimensions, screenTileSize, playerViewpoint
  21.   viewOff = point(playerViewpoint[1] mod screenTileSize, playerViewpoint[2] mod screenTileSize)
  22.   maxX = screenDimensions[1]
  23.   maxY = screenDimensions[2]
  24.   wTile = 0
  25.   repeat with whichY = 1 to maxY
  26.     repeat with whichX = 1 to maxX
  27.       wSprite = terrainSO + wTile
  28.       set the loc of sprite wSprite to point((whichX - 1) * screenTileSize, (whichY - 1) * screenTileSize) - viewOff + (screenTileSize / 2)
  29.       wTile = wTile + 1
  30.     end repeat
  31.   end repeat
  32. end
  33.  
  34. on checkSolidpoint pointLoc
  35.   global terrainData_Type, screenTileSize, playerViewpoint, terrainRef
  36.   tilePointSet = (pointLoc / screenTileSize) + 1
  37.   if (tilePointSet[2] >= 1) and (tilePointSet[2] <= count(terrainData_Type)) and (tilePointSet[1] >= 1) and (tilePointSet[1] <= count(terrainData_Type[1])) then
  38.     bType = terrainData_Type[tilePointSet[2]][tilePointSet[1]]
  39.   else
  40.     bType = 2
  41.   end if
  42.   return [terrainRef[bType][2], terrainRef[bType][5]]
  43. end
  44.  
  45. on punchBlock punchPoint
  46.   global terrainData_Type, screenTileSize, playerViewpoint, locksOpened, terrainRef, playerInventory
  47.   tilePointSet = (punchPoint / screenTileSize) + 1
  48.   if (tilePointSet[2] >= 1) and (tilePointSet[2] <= count(terrainData_Type)) and (tilePointSet[1] >= 1) and (tilePointSet[1] <= count(terrainData_Type[1])) then
  49.     bType = terrainData_Type[tilePointSet[2]][tilePointSet[1]]
  50.   else
  51.     bType = 1
  52.   end if
  53.   if (playerInventory[2] > 0) and (terrainRef[bType][5] = 5) then
  54.     openLockNOW = 1
  55.   else
  56.     openLockNOW = 0
  57.   end if
  58.   tType = terrainRef[bType][5]
  59.   if (tType = 1) or (tType = 6) or (tType = 7) or (tType = 8) or (tType = 9) or (openLockNOW = 1) then
  60.     terrainData_Type[tilePointSet[2]][tilePointSet[1]] = 1
  61.     rpoint = (tilePointSet * 50) - 25
  62.     addparticle(rpoint, 0, 1)
  63.     put terrainRef[bType][5]
  64.     case terrainRef[bType][5] of
  65.       1:
  66.       5:
  67.         playerInventory[2] = playerInventory[2] - 1
  68.         if updateTextFields = 1 then
  69.           member("Key Display").text = string(playerInventory[2])
  70.         end if
  71.         locksOpened = locksOpened + 1
  72.       6:
  73.         repeat with wCoin = 1 to 1
  74.           addPickup(1, 1, rpoint, point(random(7) - 4, -6 - random(12)))
  75.         end repeat
  76.       7:
  77.         repeat with wCoin = 1 to 1
  78.           addPickup(1, 2, rpoint, point(random(7) - 4, -6 - random(12)))
  79.         end repeat
  80.       8:
  81.         repeat with wCoin = 1 to 3
  82.         end repeat
  83.       9:
  84.         repeat with wCoin = 1 to 1
  85.           addPickup(1, 3, rpoint, point(0, 0))
  86.         end repeat
  87.     end case
  88.     addScore(5)
  89.   end if
  90. end
  91.  
  92. on redrawTerrainPics
  93.   global terrainSO, screenDimensions, screenTileSize, terrainData_Type, playerViewpoint, tilePointSet, animNumber, terrainRef
  94.   tilePointSet = playerViewpoint / screenTileSize
  95.   maxX = screenDimensions[1]
  96.   maxY = screenDimensions[2]
  97.   wTile = 0
  98.   repeat with whichY = 1 to maxY
  99.     repeat with whichX = 1 to maxX
  100.       wSprite = terrainSO + wTile
  101.       bType = terrainData_Type[whichY + tilePointSet[2]][whichX + tilePointSet[1]]
  102.       blockString = terrainRef[bType]
  103.       if count(blockString[1]) = 1 then
  104.         set the member of sprite wSprite to blockString[1][1]
  105.       else
  106.         frameNum = (animNumber mod count(blockString[1])) + 1
  107.         set the member of sprite wSprite to blockString[1][frameNum]
  108.       end if
  109.       case blockString[3] of
  110.         0:
  111.           sprite(wSprite).visible = 0
  112.         1:
  113.           sprite(wSprite).locZ = 199
  114.           set the ink of sprite wSprite to 36
  115.           sprite(wSprite).visible = 1
  116.         2:
  117.           sprite(wSprite).locZ = 201
  118.           set the ink of sprite wSprite to 36
  119.           sprite(wSprite).visible = 1
  120.         3:
  121.           sprite(wSprite).locZ = 201
  122.           set the ink of sprite wSprite to 33
  123.           sprite(wSprite).visible = 1
  124.       end case
  125.       wTile = wTile + 1
  126.     end repeat
  127.   end repeat
  128. end
  129.